package cfs.formbean;

import java.util.ArrayList;
import java.util.List;

import org.mybeans.form.FormBean;

public class LoginForm extends FormBean {
	private String userName;
	private String password;
	private String type;

	public String getUserName() {
		return userName;
	}

	public String getPassword() {
		return password;
	}

	public void setUserName(String s) {
		// userName = trimAndConvert(s, "<>\"");
		userName = s.trim();
	}

	public void setPassword(String s) {
		password = s.trim();
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public List<String> getValidationErrors() {
		List<String> errors = new ArrayList<String>();

		if (userName == null || userName.length() == 0) {
			errors.add("User Name is required");
                        return errors;
		}

		if (password == null || password.length() == 0) {
			errors.add("Password is required");
                        return errors;
		}

		if (userName.matches(".*[<>\"].*")){
			errors.add("user name may not contain angle brackets or quotes");
                        return errors;
                }
		if (password.matches(".*[<>\"].*"))
			errors.add("password  may not contain angle brackets or quotes");

		return errors;
	}
}